<!DOCTYPE html>
<html lang="zh-Hans">
  <head>
    
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>


<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<meta name="theme-color" content="#f8f5ec" />
<meta name="msapplication-navbutton-color" content="#f8f5ec">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="#f8f5ec">



  <meta name="description" content="关于技术,编程,摄影,读书的心路历程"/>













  <link rel="alternate" href="/atom.xml" title="杂鱼君的博客">




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=2.6.0" />



<link rel="canonical" href="http://notes.wen.moe/page/3/"/>


<link rel="stylesheet" type="text/css" href="/css/style.css?v=2.6.0" />



  <link rel="stylesheet" type="text/css" href="/lib/fancybox/jquery.fancybox.css" />




  



  <script id="baidu_push">
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>









    <title> 杂鱼君的博客 </title>
  </head>

  <body><div id="mobile-navbar" class="mobile-navbar">
  <div class="mobile-header-logo">
    <a href="/." class="logo">杂鱼君的博客</a>
  </div>
  <div class="mobile-navbar-icon">
    <span></span>
    <span></span>
    <span></span>
  </div>
</div>

<nav id="mobile-menu" class="mobile-menu slideout-menu">
  <ul class="mobile-menu-list">
    
      <a href="/">
        <li class="mobile-menu-item">
          
          
            Home
          
        </li>
      </a>
    
      <a href="/archives/">
        <li class="mobile-menu-item">
          
          
            Archives
          
        </li>
      </a>
    
      <a href="/tags">
        <li class="mobile-menu-item">
          
          
            Tags
          
        </li>
      </a>
    
      <a href="/about">
        <li class="mobile-menu-item">
          
          
            About
          
        </li>
      </a>
    
  </ul>
</nav>

    <div class="container" id="mobile-panel">
      <header id="header" class="header"><div class="logo-wrapper">
  <a href="/." class="logo">杂鱼君的博客</a>
</div>

<nav class="site-navbar">
  
    <ul id="menu" class="menu">
      
        <li class="menu-item">
          <a class="menu-item-link" href="/">
            
            
              Home
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/archives/">
            
            
              Archives
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/tags">
            
            
              Tags
            
          </a>
        </li>
      
        <li class="menu-item">
          <a class="menu-item-link" href="/about">
            
            
              About
            
          </a>
        </li>
      
    </ul>
  
</nav>

      </header>

      <main id="main" class="main">
        <div class="content-wrapper">
          <div id="content" class="content">
            
  <section id="posts" class="posts">
    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/install-lnmp-on-elementary-os.html">在elementary os 上安装LNMP</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-05-15
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p><em>elementary os 是基于ubuntu的，所以步骤和ubuntu类似</em></p>
<p>最近换了新设备,老电脑就空下来了.折腾着在上面装了<a href="http://https://elementary.io/" target="_blank" rel="external">elementary os</a> 系统，尝试着在这个系统上搭建开发环境。</p>
          <div class="read-more">
            <a href="/post/install-lnmp-on-elementary-os.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/install-jekyll-on-elementary-os.html">在elementary OS/ubuntu安装jekyll</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-05-13
        </span>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        

        
          <p>使用jekyll来搭建博客是一件很惬意的事情.不需要服务器,甚至域名都不需要.不过在本地搭建一个jekyll环境还是很必要,否则每次都要推到github才能预览效果岂不是很蛋疼?</p>
<h2 id="安装-nodejs"><a href="#安装-nodejs" class="headerlink" title="安装 nodejs"></a>安装 nodejs</h2><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo apt-<span class="builtin-name">get</span> install nodejs</div></pre></td></tr></table></figure>
<h2 id="安装ruby-和-rubygem"><a href="#安装ruby-和-rubygem" class="headerlink" title="安装ruby 和 rubygem"></a>安装ruby 和 rubygem</h2><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">sudo</span> <span class="selector-tag">apt-get</span> <span class="selector-tag">install</span> <span class="selector-tag">ruby</span> <span class="selector-tag">ruby1</span><span class="selector-class">.9</span><span class="selector-class">.1-dev</span></div></pre></td></tr></table></figure>
<h3 id="更换ruby的镜像服务器"><a href="#更换ruby的镜像服务器" class="headerlink" title="更换ruby的镜像服务器"></a>更换ruby的镜像服务器</h3><figure class="highlight groovy"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">sudo gem sources --remove <span class="string">http:</span><span class="comment">//rubygems.org/</span></div><div class="line">sudo gem sources -a <span class="string">http:</span><span class="comment">//ruby.taobao.org/</span></div></pre></td></tr></table></figure>
<h2 id="安装jekyll"><a href="#安装jekyll" class="headerlink" title="安装jekyll"></a>安装jekyll</h2><figure class="highlight cmake"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">sudo gem <span class="keyword">install</span> jekyll</div></pre></td></tr></table></figure>
<p>然后就可以通过<code>jekyll serve</code>启动jekyll了.</p>

        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/install-my-common-software-on-ubuntu.html">Ubuntu上个人常用软件的安装方法</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-04-12
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p><em>以下软件有些需要翻墙，具体怎么做就不说了</em></p>
<p>对于程序员来说，Ubuntu比Windows更适合作为日常使用的操作系统(好用个P,OSX赛高!)，当然前<br>提是不喜欢玩游戏。安装系统非常简单，但是一些在windows上常用的软件安装起来还真费了些事，就把他记录在这里把。</p>
          <div class="read-more">
            <a href="/post/install-my-common-software-on-ubuntu.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/learn-design-patterns-observer.html">设计模式的学习--观察者模式</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-01-29
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>为了更愉快的装逼,开始学习php的设计模式之二.</p>
<p>###特点</p>
<ol>
<li>由一个观察者对应多个被观察者,一对多的关系</li>
<li>被观察者预留update()方法给观察者调用</li>
</ol>
          <div class="read-more">
            <a href="/post/learn-design-patterns-observer.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/learn-design-patterns-singleton.html">设计模式的学习--单例模式</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-01-28
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>为了更愉快的装逼,开始学习php的设计模式.</p>
<p>###特点</p>
<ol>
<li>一个类有且只有一个实例</li>
<li>这个实例是由这个类本身创建的</li>
<li>自行向整个逻辑返回本身的实例</li>
</ol>
          <div class="read-more">
            <a href="/post/learn-design-patterns-singleton.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/how-to-reorder-an-array-by-Specific-rule.html">如何按照给定的顺序重新排序一个数组?</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2015-01-26
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>segmentfault上有人提了个<a href="http://segmentfault.com/q/1010000000185771/a-1020000002514054" target="_blank" rel="external">问题</a>,关于数组排序的,原本感觉很简单,但是我还是踩到了php自带函数的几个坑……</p>
          <div class="read-more">
            <a href="/post/how-to-reorder-an-array-by-Specific-rule.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/different-between-strtr-and-str_replace.html">strtr()和str_replace()的区别</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2014-12-25
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>工作中遇到了字符串替换的问题,查了一下php中常用的替换函数有strtr()和str_replace().分享一下我自己使用这两个函数的一些心得.</p>
          <div class="read-more">
            <a href="/post/different-between-strtr-and-str_replace.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/php-method-overload.html">手动实现PHP的方法重载</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2014-12-20
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>众所周知,由于弱类型以及特殊的解析方式的原因,PHP本身无法实现方法的重载.但是,通过PHP自带的一些强大的魔术方法,我们可以手动实现方法重载.</p>
          <div class="read-more">
            <a href="/post/php-method-overload.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/learn-php-redis.html">PHP-Redis学习实例</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2014-09-22
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        
          
        

        
          <p>Redis是一个和Memcache类似的NoSQL缓存系统.相比Memcache支持更多的数据类型,并且数据可以持久化,这让他可以储存超过指定内存大小的数据(这是我觉得和Memcache最大的区别).</p>
<p>由于支持的数据格式多,所以操作相比Memcache稍微复杂些.</p>
<p>Redis的各种赋值和取值的操作很多,网上想找个齐全的资料都不太好找.以下整理记录了一些自己常用的操作.</p>
          <div class="read-more">
            <a href="/post/learn-php-redis.html" class="read-more-link">Read more..</a>
          </div>
        
      
    </div>

    

    

  </article>

    
      
  <article class="post">
    <header class="post-header">
      <h1 class="post-title">
        
          <a class="post-link" href="/post/how-to-export-csv-file-by-php.html">php导出csv文件的一些操作</a>
        
      </h1>

      <div class="post-meta">
        <span class="post-time">
          2014-03-12
        </span>
        
          <div class="post-category">
            
              <a href="/categories/技术/">技术</a>
            
          </div>
        
        
      </div>
    </header>

    
    

    <div class="post-content">
      
        
        

        
          <p>csv文件本质上是一个由逗号以及回车分割的纯文本文件,因此导出csv文件的流程是:<br>读取信息-&gt;循环拼接成对应格式的字符串-&gt;设置header信息-&gt;导出文件（下载）</p>
<figure class="highlight php"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line"></div><div class="line"><span class="comment">//先定义一个导出的函数</span></div><div class="line"><span class="function"><span class="keyword">function</span> <span class="title">export_csv</span><span class="params">($filename,$data)</span> </span>&#123;</div><div class="line">    header(<span class="string">"Content-type:text/csv"</span>);</div><div class="line">	header(<span class="string">"Content-Disposition:attachment;filename="</span>.$filename);</div><div class="line">	<span class="keyword">echo</span> $data;</div><div class="line">&#125;</div><div class="line"></div><div class="line">$data=<span class="keyword">array</span>(</div><div class="line">    <span class="keyword">array</span>(</div><div class="line">        <span class="string">'name'</span>=&gt;<span class="string">'Kate'</span>,</div><div class="line">        <span class="string">'age'</span>=&gt;<span class="number">13</span>,</div><div class="line">        <span class="string">'num'</span>=&gt;<span class="string">'F121'</span>,</div><div class="line">    ),</div><div class="line">    <span class="keyword">array</span>(</div><div class="line">        <span class="string">'name'</span>=&gt;<span class="string">'Tom'</span>,</div><div class="line">        <span class="string">'age'</span>=&gt;<span class="number">16</span>,</div><div class="line">        <span class="string">'num'</span>=&gt;<span class="string">'M151'</span>,</div><div class="line">    ),</div><div class="line">);</div><div class="line"></div><div class="line">$str=<span class="string">"name,age,num\n"</span>;<span class="comment">//可有可无的字段名</span></div><div class="line"></div><div class="line"><span class="keyword">foreach</span>( $data <span class="keyword">as</span> $key =&gt; $value )</div><div class="line">&#123;</div><div class="line">	$str.=$value[<span class="string">'name'</span>].<span class="string">','</span>.$value[<span class="string">'age'</span>].<span class="string">','</span>.$value[<span class="string">'num'</span>].<span class="string">"\n"</span>;</div><div class="line">&#125;</div><div class="line">export_csv(<span class="string">'user.csv'</span>,$str);</div></pre></td></tr></table></figure>
<p>导出的操作很简单,重要的是关注header()的使用方法:<a href="http://php.net/manual/zh/function.header.php" target="_blank" rel="external">自定义http报文</a></p>

        
      
    </div>

    

    

  </article>

    
  </section>

  
  <nav class="pagination">
    
      <a class="prev" href="/page/2/">
        <i class="iconfont icon-left"></i>
        <span class="prev-text">Prev</span>
      </a>
    
    
      <a class="next" href="/page/4/">
        <span class="next-text">Next</span>
        <i class="iconfont icon-right"></i>
      </a>
    
  </nav>


          </div>
          

        </div>
      </main>

      <footer id="footer" class="footer">

  <div class="social-links">
    
      
        
          <a href="mailto:me@wen.moe" class="iconfont icon-email" title="email"></a>
        
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
    
      
        
          <a href="https://www.instagram.com/zakokun" class="iconfont icon-instagram" title="instagram"></a>
        
      
    
    
    
  </div>


<div class="copyright">
  <span class="power-by">
    Powered by <a class="hexo-link" href="https://hexo.io/">Hexo</a>
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    Theme -
    <a class="theme-link" href="https://github.com/ahonn/hexo-theme-even">Even</a>
  </span>
  <span class="division">|</span>
  <span class="theme-info">
    Hosted by <a class="theme-link" href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a>
  </span>

  <span class="copyright-year">
    
    &copy;
    
      2014 -
    
    2017

    <span class="heart">
      <i class="iconfont icon-heart"></i>
    </span>
    <span class="author">zakokun</span>
  </span>
</div>

      </footer>

      <div class="back-to-top" id="back-to-top">
        <i class="iconfont icon-up"></i>
      </div>
    </div>

    


    
  





  
    <script type="text/javascript" src="/lib/jquery/jquery-3.1.1.min.js"></script>
  

  
    <script type="text/javascript" src="/lib/slideout/slideout.js"></script>
  

  
    <script type="text/javascript" src="/lib/fancybox/jquery.fancybox.pack.js"></script>
  


    <script type="text/javascript" src="/js/src/even.js?v=2.6.0"></script>
<script type="text/javascript" src="/js/src/bootstrap.js?v=2.6.0"></script>

  </body>
</html>
